package ru.st.selenium.applogic2;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import ru.st.selenium.applogic.FilmHelper;
import ru.st.selenium.model.Film;
import ru.st.selenium.model.User;
import ru.st.selenium.pages.AddMovie;
import ru.st.selenium.pages.MovieDescriptionPage;
import ru.st.selenium.pages.MyCollectionPage;
import ru.st.selenium.pages.UserProfilePage;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

  public FilmHelper2(ApplicationManager2 manager) {
    super(manager.getWebDriver());
  }
 
  @Override
  public void create(Film film) {
	  pages.addFilmPage.ensurePageLoaded()
	  .setTitleField(film.getTitle())
	  .setYearField(film.getYear())
	  .clickSubmitButton();
  }

  @Override
  public void delete(Film film) {
	  pages.movieDescriptionPage.ensurePageLoaded().clickDeleteFilmLink();
  }
  
  @Override
  public boolean filmIsAdded() {
	  return pages.movieDescriptionPage.waitPageLoaded();
  }
  
  @Override
  public boolean filmIsNotAdded() {
	  	return pages.addFilmPage.fieldIsWrong();
  }
  
  @Override
  public boolean filmIsFounded(String title){
	  pages.myCollectionPage.clickMovieTitle(title);
	  return pages.movieDescriptionPage.waitPageLoaded();
  }
  
  @Override
  public boolean filmNotFound(){
	  return pages.myCollectionPage.waitPageLoaded();
  }
  
  @Override
  public void searchFilm(String title){  ///////////// search
	  pages.myCollectionPage.clickSearchField()
	  .setSearchField(title);
  }

  
  @Override
  public List<WebElement> search(String title) {
	  return null;
  }

}
